package com.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.VpnPeizhiDao;
import com.pojo.VpnPeizhi;
import com.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class VpnPeizhiService extends ServiceImpl<VpnPeizhiDao, VpnPeizhi> {

    @Autowired
    private VpnPeizhiDao vpnPeizhiDao;

    public IPage selectIP_yuming(int page, int limit, String name) {
        Page p = new Page(page, limit);
        QueryWrapper<VpnPeizhi> query = new QueryWrapper();

        if(StringUtil.isNotNull(name)) {
            query.and(wrapper->wrapper.like("ip_address" , name).or().like("yu_ming",name));
        }
        IPage iPage = vpnPeizhiDao.selectPage(p, query);
        return iPage;
    }
}
